Skip to content

Integrate Application Insights and OpenTelemetry for CLI observability#1838

Merged
krusty93 merged 4 commits into
mainfrom
CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli
Jun 26, 2026
Merged

Integrate Application Insights and OpenTelemetry for CLI observability#1838
krusty93 merged 4 commits into
mainfrom
CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli

Conversation

@krusty93

@krusty93 krusty93 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Implement OpenTelemetry logging for improved observability, including root span tracing for CLI commands. Enhance telemetry capabilities by concurrently fetching tool versions and adding Azure Monitor service name.

@krusty93

Copy link
Copy Markdown
Contributor Author

Few screenshots:

Operation duration and status:
image

Log events using logtape open telemetry sink (console.error/info/debug/etc.):
image

Each span logs the dependencies:
image

@gunzip

gunzip commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Since the CLI is a public package available to anyone, any tracking mechanism must be opt-in and accompanied by a privacy policy. The same applies to pipelines. Alternatively, we must restrict tracking to internal usage only

@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 3164682 to bffee13 Compare June 12, 2026 13:33
@krusty93

krusty93 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Since the CLI is a public package available to anyone, any tracking mechanism must be opt-in and accompanied by a privacy policy. The same applies to pipelines. Alternatively, we must restrict tracking to internal usage only

restricted to pagopa users only, via github

@krusty93 krusty93 marked this pull request as ready for review June 12, 2026 13:46
@krusty93 krusty93 requested a review from a team as a code owner June 12, 2026 13:46
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from bffee13 to 85a4b82 Compare June 15, 2026 08:15
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch 2 times, most recently from ecff58e to 0d4b05f Compare June 15, 2026 08:21
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 0d4b05f to fa45050 Compare June 15, 2026 08:48
Copilot AI review requested due to automatic review settings June 15, 2026 08:56
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 03201bb to 80b449d Compare June 15, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end observability for the dx CLI by integrating Azure Monitor (Application Insights) and OpenTelemetry, including a single root span for each CLI invocation and log export via Logtape → OTel. It also tightens CLI preconditions (GitHub auth) and updates workspace dependency catalogs/lockfiles accordingly.

Changes:

  • Add Azure Monitor/OpenTelemetry preload + runtime enablement, root span tracing, and OTel log sink wiring for the CLI.
  • Enforce GitHub authentication for all CLI commands except --help/--version, with telemetry enabled only for pagopa org members.
  • Update dependency catalogs/lockfile and documentation to reflect new auth + telemetry behavior.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds/updates OpenTelemetry-related catalog entries and normalizes quoting/format.
pnpm-lock.yaml Updates lockfile to include new OTel/Logtape/Azure Monitor dependencies and related transitive changes.
package.json Updates packageManager and adds pnpm overrides at root.
apps/website/docs/dx-cli/requirements.md Documents mandatory GitHub auth and telemetry enablement rules.
apps/cli/src/index.ts Adds early auth/telemetry gating, OTel log sink, root span lifecycle, and tool-version enrichment.
apps/cli/src/adapters/plop/actions/setup-pnpm.ts Strips debugger-related env vars from spawned processes.
apps/cli/src/adapters/octokit/index.ts Adds isPagopaOrgMember helper to gate telemetry.
apps/cli/src/adapters/octokit/tests/index.test.ts Adds unit tests for isPagopaOrgMember.
apps/cli/src/adapters/commander/commands/doctor.ts Avoids process.exit() to allow telemetry flush in finally.
apps/cli/src/adapters/commander/commands/add.ts Extends action result shape to include the environment payload.
apps/cli/src/adapters/azure-monitor/telemetry.ts Adds flushTelemetry() helper to shutdown/flush Azure Monitor SDK safely.
apps/cli/src/adapters/azure-monitor/instrumentation.ts Adds preload module hook registration + Azure Monitor enablement and resource attribute setup.
apps/cli/README.md Documents GitHub auth requirement and telemetry scope.
apps/cli/package.json Adds Azure Monitor + OTel deps and Logtape OTel sink deps to the CLI app.
apps/cli/bin/index.js Ensures instrumentation preload is imported before the CLI entrypoint via sequential dynamic imports.
.nx/version-plans/version-plan-1781270390103.md Version plan for docs change (GitHub login requirement).
.nx/version-plans/version-plan-1781270291055.md Version plan for CLI telemetry behavior change.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread apps/cli/src/adapters/azure-monitor/instrumentation.ts
Comment thread apps/cli/src/adapters/azure-monitor/instrumentation.ts Outdated
Comment thread apps/cli/README.md Outdated
Comment thread apps/cli/README.md Outdated
Comment thread package.json Outdated
Comment thread pnpm-workspace.yaml
Comment thread apps/cli/src/index.ts
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 94ef95f to 6f50e56 Compare June 15, 2026 09:31
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 6f50e56 to 1ab8c3b Compare June 15, 2026 10:06
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 1ab8c3b to 16ac30e Compare June 16, 2026 12:55
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 16ac30e to b1cfcc6 Compare June 16, 2026 12:57
@krusty93 krusty93 added the priority A review is required ASAP label Jun 16, 2026
Comment thread apps/cli/src/adapters/azure-monitor/instrumentation.ts
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from b1cfcc6 to c2de757 Compare June 16, 2026 13:51
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from c2de757 to ce583b9 Compare June 22, 2026 09:56
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from ce583b9 to 91213a8 Compare June 23, 2026 08:57
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 91213a8 to 4b7d615 Compare June 23, 2026 15:12
@krusty93 krusty93 requested a review from gunzip June 24, 2026 08:32
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 7ae754a to 03f40ac Compare June 24, 2026 08:32
@krusty93 krusty93 requested review from kin0992 and mamu0 June 24, 2026 08:32
@krusty93 krusty93 force-pushed the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch from 03f40ac to aa73aec Compare June 24, 2026 09:04
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-mud-0405c6703-1838.westeurope.1.azurestaticapps.net

@krusty93 krusty93 merged commit 3f6bae6 into main Jun 26, 2026
10 checks passed
@krusty93 krusty93 deleted the CES-1615-tracciare-con-application-insights-lutilizzo-ed-eventuali-errori-della-dx-cli branch June 26, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority A review is required ASAP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants